package com.lagou.servlet;

import com.lagou.model.Request;
import com.lagou.model.Response;

/**
 * @author Kirito
 * @description:
 * @date 2020/04/25
 */
public abstract class HttpServlet implements Servlet {
    @Override
    public void init() throws Exception {

    }

    @Override
    public void destroy() throws Exception {

    }

    @Override
    public void service(Request request, Response response) throws Exception {
        String method = request.getMethod();
        if ("GET".equalsIgnoreCase(method)) {
            doGet(request, response);
        } else {
            doPost(request, response);
        }
    }

    protected abstract void doGet(Request request, Response response) throws Exception;

    protected abstract void doPost(Request request, Response response) throws Exception;
}
